package com.ambitor.ipro.interceptors;

import com.ambitor.ipro.actions.IBaseAction;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class BaseInterceptor implements Interceptor {

	private static final long	serialVersionUID	= -518060355021333950L;

	@Override
	public void destroy() {
	}

	@Override
	public void init() {
	}

	@Override
	public String intercept(ActionInvocation actionInvocation) throws Exception {
		String invokeResult = actionInvocation.invoke();
		Action action = (Action) actionInvocation.getAction();
		if (action instanceof IBaseAction) {
			((IBaseAction) action).commit();
			((IBaseAction) action).close();
		}
		return invokeResult;
	}
}
